package com.yugu.park.config;


import com.yugu.park.task.BackupTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;



@Configuration
@EnableScheduling
@Slf4j
public class SchedulingConfig {
	@Autowired
	private BackupTask task;

	@Scheduled(cron = "0 55 23 * * *")
	public void leberDbBackup() {
		try {
			task.doBackup();
			log.error("执行跑批任务，备份数据库");
		} catch (Exception e) {
			log.error("执行跑批任务，备份数据库失败", e);
		}
	}

}
